package com.fate.securecheckplatform.db;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

import com.fate.securecheckplatform.bean.TableForbiddenPerformance;
import com.fate.securecheckplatform.bean.TableForbiddenType;
import com.fate.securecheckplatform.bean.TerminalInfoEntity;
import com.fate.securecheckplatform.bean.UserEntity;

@Database(entities = {UserEntity.class, TableForbiddenPerformance.class,
        TableForbiddenType.class, TerminalInfoEntity.class}, version = 21,exportSchema = false)
@TypeConverters(TableForbiddenThingCoverter.class)
public abstract class DataBase extends RoomDatabase {

    private static final Object sLock = new Object();
    private static DataBase INSTANCE;

    public static DataBase getInstance(Context context) {
        synchronized (sLock) {
            if (INSTANCE == null) {
                INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                        DataBase.class,
                        "secure_check_platform.db")
                        .fallbackToDestructiveMigration()
                        .build();
            }
            return INSTANCE;
        }
    }

    public abstract UserDao userDao();

    public abstract ForbiddenPerformanceDao forbiddenObjectDao();

    public abstract ForbiddenTypeDao forbiddenTypeDao();

    public abstract TerminalDao terminalDao();

}
